Skip to content

Conversation

@rhettinger
Copy link
Contributor

@rhettinger rhettinger commented Jan 11, 2026

Match the parallel examples for grouper:

def grouper(iterable, n, *, incomplete='fill', fillvalue=None):
    "Collect data into non-overlapping fixed-length chunks or blocks."
    # grouper('ABCDEFG', 3, fillvalue='x') → ABC DEF Gxx
    # grouper('ABCDEFG', 3, incomplete='strict') → ABC DEF ValueError
    # grouper('ABCDEFG', 3, incomplete='ignore') → ABC DEF
    iterators = [iter(iterable)] * n
    match incomplete:
        case 'fill':
            return zip_longest(*iterators, fillvalue=fillvalue)
        case 'strict':
            return zip(*iterators, strict=True)
        case 'ignore':
            return zip(*iterators)
        case _:
            raise ValueError('Expected fill, strict, or ignore')

📚 Documentation preview 📚: https://cpython-previews--143676.org.readthedocs.build/

@rhettinger rhettinger added docs Documentation in the Doc dir skip issue skip news 3.15 new features, bugs and security fixes labels Jan 11, 2026
@github-project-automation github-project-automation bot moved this to Todo in Docs PRs Jan 11, 2026
@rhettinger rhettinger merged commit 75d73c3 into python:main Jan 11, 2026
39 checks passed
@github-project-automation github-project-automation bot moved this from Todo to Done in Docs PRs Jan 11, 2026
@rhettinger rhettinger deleted the sync_batched_grouper_examples branch January 11, 2026 04:00
@rhettinger rhettinger added the needs backport to 3.14 bugs and security fixes label Jan 11, 2026
@miss-islington-app
Copy link

Thanks @rhettinger for the PR 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jan 11, 2026
(cherry picked from commit 75d73c3)

Co-authored-by: Raymond Hettinger <rhettinger@users.noreply.github.com>
@bedevere-app
Copy link

bedevere-app bot commented Jan 11, 2026

GH-143678 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.14 bugs and security fixes label Jan 11, 2026
@rhettinger rhettinger added the needs backport to 3.13 bugs and security fixes label Jan 11, 2026
@miss-islington-app
Copy link

Thanks @rhettinger for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jan 11, 2026
(cherry picked from commit 75d73c3)

Co-authored-by: Raymond Hettinger <rhettinger@users.noreply.github.com>
@bedevere-app
Copy link

bedevere-app bot commented Jan 11, 2026

GH-143679 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.13 bugs and security fixes label Jan 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3.15 new features, bugs and security fixes docs Documentation in the Doc dir skip issue skip news

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant